package pl.shenlon.poker.gui;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.KeyStroke;

import net.miginfocom.swing.MigLayout;
import pl.shenlon.assets.Assets;
import pl.shenlon.ga.Specimen;

public class SpecimenDataViewDialog extends JDialog {
	public static final Dimension DEFAULT_SIZE;
	static {
		// DEFAULT_SIZE = new Dimension(600, 400);
		DEFAULT_SIZE = (Dimension) Assets
				.get("@dimensions/specimenDataViewDialog");
	}

	private SpecimenDataView specimenDataView;

	public SpecimenDataViewDialog() {
		initComponent();
		setSize(DEFAULT_SIZE);
		// pack();
		setTitle("Szczegóły osobnika");
		setModal(true);
		setLocationRelativeTo(null);
	}

	private void initComponent() {
		Container contentPane = getContentPane();
		contentPane.setLayout(new MigLayout("fill"));

		specimenDataView = new SpecimenDataView();
		contentPane.add(specimenDataView, "grow");
		getRootPane().registerKeyboardAction(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent event) {
				setVisible(false);
			}
		}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
				JComponent.WHEN_IN_FOCUSED_WINDOW);
		
	}

	public void setSpecimen(Specimen specimen) {
		specimenDataView.setSpecimen(specimen);
	}

}